package com.LeeCode;

/**
 * 整数反转
 */

public class Code007 {
    public static void main(String[] args) {
        int x = 1534236469;
        System.out.println(new Code007().reverse(x));
    }

    public int reverse(int x) {
        int ans = 0;

        while (x != 0) {
            if (ans < Integer.MIN_VALUE / 10 || ans > Integer.MAX_VALUE / 10) {
                return 0;
            }
            ans = ans * 10 + x % 10;
            x /= 10;
        }
        return ans;
    }
}
